package com.itheima.app.controller;

import com.itheima.app.interceptor.UserHolder;
import com.itheima.app.manager.MakeFriendManager;
import com.itheima.app.manager.UserLikeManager;
import com.itheima.domain.vo.PageBeanVo;
import com.itheima.domain.vo.UserLikeCountVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class UserLikeController {

    @Autowired
    private UserLikeManager userLikeManager;


    @Autowired
    private MakeFriendManager makeFriendManager;

    /**
     * 喜欢
     * @param userLikeId
     * @return
     */
    @GetMapping("/tanhua/{id}/love")
    public Map saveUserLike(@PathVariable("id")Long userLikeId) {
        userLikeManager.saveUserLike(userLikeId);
        return null;

    }
    /**
     * 不喜欢
     */
    @GetMapping("/tanhua/{id}/unlove")
    public Map deleteUserLike(@PathVariable("id")Long userDislikeId) {
        userLikeManager.deleteUserLike(userDislikeId);
        return null;

    }
    /**
     * 查看我的 互相喜欢，喜欢，粉丝 - 统计
     */
    @GetMapping("/users/counts")
    public UserLikeCountVo usersCounts() {
        return userLikeManager.userCounts();

    }


    /**
     * 查看   互相喜欢、喜欢、粉丝、历史访客 - 翻页列表
     */
    @GetMapping("/users/friends/{type}")
    public PageBeanVo findUserList(@PathVariable("type")Integer type,
            @RequestParam(defaultValue = "1" , name = "page") Integer pageNumber ,
            @RequestParam(defaultValue = "10", name = "pagesize" )Integer pageSize ) {
        return userLikeManager.findUserList(pageNumber, pageSize, type);

    }

    /**
     * 粉丝 ---喜欢
     * @param uid
     * @return
     */
    @PostMapping("/users/fans/{uid}")
    public Map saveFanLike(@PathVariable("uid") Long uid ) {
        userLikeManager.saveUserLike(uid);
        return null;
    }

    /**
     * 粉丝 ---取消喜欢
     * @param uid
     * @return
     */
    @DeleteMapping("/users/like/{uid}")
    public Map deleteLike(@PathVariable("uid") Long uid ) {
        userLikeManager.deleteLike(uid);
        return null;
    }



}
